<template>
  <div class="login-phone">
    <el-form label-width="60px" :model="phone" :rules="rules" ref="formRef">
      <el-form-item label="手机号:" prop="number">
        <el-input v-model="phone.number"></el-input>
      </el-form-item>
      <el-form-item label="验证码:" prop="verifyCode">
        <div class="verify">
          <el-input v-model="phone.verifyCode"></el-input>
          <el-button type="primary" class="get-btn">获取验证码</el-button>
        </div>
      </el-form-item>
    </el-form>
  </div>
</template>

<script lang="ts">
import { ElForm } from 'element-plus'
import { defineComponent, reactive, ref } from 'vue'
import { rules } from '../config/account-config'

export default defineComponent({
  setup() {
    const phone = reactive({
      number: '',
      verifyCode: ''
    })

    const formRef = ref<InstanceType<typeof ElForm>>()
    const loginAction = () => {
      formRef.value?.validate((valid) => {
        if (valid) {
          console.log('执行手机号登录')
        } else {
          console.log('请输入正确的信息')
        }
      })
    }

    return {
      rules,
      phone,
      loginAction
    }
  }
})
</script>

<style scoped>
.verify {
  display: flex;
}
.get-btn {
  margin-left: 10px;
}
</style>
